﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Driver.aspx.cs" Inherits="Mercator2.UI.Driver" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <p>
    Cadastro de Motoristas</p>
    <p>
    <asp:Button ID="btnSearch" runat="server" onclick="btnSearch_Click" 
        Text="Procurar por nome:" Width="186px" />
    <asp:TextBox ID="txtDriverName" runat="server" Width="256px"></asp:TextBox>
    </p>
<p>
    <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" 
        AutoGenerateRows="False" BackColor="White" BorderColor="#E7E7FF" 
        BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="DriverID" 
        DataSourceID="DriverDataSource" GridLines="Horizontal" Height="50px" 
        Width="334px">
        <AlternatingRowStyle BackColor="#F7F7F7" />
        <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <Fields>
            <asp:BoundField DataField="DriverID" HeaderText="Código" InsertVisible="False" 
                ReadOnly="True" SortExpression="DriverID" />
            <asp:BoundField DataField="DriverName" HeaderText="Nome" 
                SortExpression="DriverName" />
            <asp:BoundField DataField="DriverLicense" HeaderText="CNH" 
                SortExpression="DriverLicense" />
            <asp:BoundField DataField="DriverEmail" HeaderText="E-mail" 
                SortExpression="DriverEmail" />
            <asp:BoundField DataField="DriverAddress" HeaderText="Endreço" 
                SortExpression="DriverAddress" />
            <asp:BoundField DataField="DriverSSN" HeaderText="CPF" 
                SortExpression="DriverSSN" />
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                ShowInsertButton="True" />
        </Fields>
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
    </asp:DetailsView>
    <asp:SqlDataSource ID="DriverDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MERCATOR_histConnectionString %>" 
        DeleteCommand="DELETE FROM [Driver] WHERE [DriverID] = @DriverID" 
        InsertCommand="INSERT INTO [Driver] ([DriverName], [DriverLicense], [DriverEmail], [DriverAddress], [DriverSSN]) VALUES (@DriverName, @DriverLicense, @DriverEmail, @DriverAddress, @DriverSSN)" 
        SelectCommand="SELECT * FROM [Driver] ORDER BY [DriverName]" 
        UpdateCommand="UPDATE [Driver] SET [DriverName] = @DriverName, [DriverLicense] = @DriverLicense, [DriverEmail] = @DriverEmail, [DriverAddress] = @DriverAddress, [DriverSSN] = @DriverSSN WHERE [DriverID] = @DriverID">
        <DeleteParameters>
            <asp:Parameter Name="DriverID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="DriverName" Type="String" />
            <asp:Parameter Name="DriverLicense" Type="String" />
            <asp:Parameter Name="DriverEmail" Type="String" />
            <asp:Parameter Name="DriverAddress" Type="String" />
            <asp:Parameter Name="DriverSSN" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="DriverName" Type="String" />
            <asp:Parameter Name="DriverLicense" Type="String" />
            <asp:Parameter Name="DriverEmail" Type="String" />
            <asp:Parameter Name="DriverAddress" Type="String" />
            <asp:Parameter Name="DriverSSN" Type="String" />
            <asp:Parameter Name="DriverID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
</p>
</asp:Content>
